package com.chenglu.android.restaurant.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.index.selectcity.citypicker.utils.StringUtils;
import com.chenglu.android.restaurant.bean.GoodscategorylisBean;

import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023 3 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：满减
 */
public class ShopCategoryGoodAdapter extends BaseQuickAdapter<GoodscategorylisBean.DataBean, BaseViewHolder> {

    Context mContext;

    public ShopCategoryGoodAdapter(Context context, @Nullable List<GoodscategorylisBean.DataBean> data) {
        super(R.layout.item_shopcategory_good, data);
        this.mContext = context;
    }


    @Override
    protected void convert(@NonNull BaseViewHolder helper, GoodscategorylisBean.DataBean item) {
        if (TextUtils.isEmpty(item.getPic())) {
            helper.setGone(R.id.tv_item_shopcategory_good, true);
            helper.setText(R.id.tv_item_shopcategory_good, item.getCategoryName());
            helper.setGone(R.id.iv_item_shopcategory_good, false);
        } else {
            helper.setGone(R.id.tv_item_shopcategory_good, false);
            helper.setGone(R.id.iv_item_shopcategory_good, true);
            ImageView imageView = helper.getView(R.id.iv_item_shopcategory_good);
            Glide.with(mContext).load(item.getPic()).into(imageView);
        }

        RecyclerView recyclerView=helper.getView(R.id.rv_item_shopcategory_good);
        ShopCategoryGoodItemAdapter shopCategoryGoodAdapter= new ShopCategoryGoodItemAdapter(mContext, item.getGoodsVOList());
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(shopCategoryGoodAdapter);


    }

}
